package acm.蓝桥3;

import java.util.Scanner;

public class 糖果 {
    static int N = 10000000;
    static int[] nums = new int[2];

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        nums[0] = sc.nextInt();
        nums[1] = sc.nextInt();
        int res = dpFun(N, nums.length);
        System.out.println(res);
    }

    public static int dpFun(int rest, int n) {
        boolean[][] dp = new boolean[rest + 1][n + 1];
        for (int i = 0; i <= n; i++) {
            dp[0][i] = true;
        }
        int res = 0;
        for (int i = 1; i <= rest; i++) {
            boolean flag = false;
            for (int j = 1; j <= n; j++) {
                if (i - nums[j - 1] < 0) {
                    dp[i][j] = dp[i][j - 1];
                } else {
                    dp[i][j] = dp[i][j - 1] || dp[i - nums[j - 1]][j];
                }
                flag = flag || dp[i][j];
            }
            if (!flag) {
                res = i;
            }
        }
        return res;
    }

    public static boolean check(int rest, int i) {
        if (rest == 0) {
            return true;
        }
        if (rest < 0 || i < 0) {
            return false;
        }
        return check(rest, i - 1) || check(rest - nums[i], i);
    }
}
